﻿using Microsoft.AspNetCore.Components;
using System.Collections.Generic;
using System.Linq;

namespace BootstrapBlazor.Components
{
    public partial class RadioListX<TValue> : RadioList<TValue>
    {
        /// <summary>
        /// 选项是否不能为空，是的话就会自动去掉空值的选项
        /// </summary>
        [Parameter]
        public bool isNotNull { get; set; }
        protected override void OnParametersSet()
        {
            base.OnParametersSet();

            var t = NullableUnderlyingType ?? typeof(TValue);
            if (Items != null && isNotNull)
            {
                Items = Items.Where(x => !string.IsNullOrEmpty(x.Value)).ToList();   
            }
        }
    }
}
